mui.init();
/*
 * 忘记密码跳转
 */
mui('body').on('tap', '#forget_password', function() {
	window.top.location.href = "retrieve_pwd.html"
});
/*
 * 登录——确定
 */
//document.getElementById("login").addEventListener("tap", function() {
mui('body').on('tap', '#login', function() {
	var phone_number = $("#phone_number").val(); //手机号码
	var phone_pwd = $("#phone_password").val(); //密码
	if(!phone_number) {
		mui.alert("请输入手机号码！")
		return false;
	}
	if(!phone_pwd) {
		mui.alert("请输入密码！")
		return false;
	}
	interfRequest.login.data = {
		account: phone_number,
		password: phone_pwd
	}
	socialRequest(interfRequest.login);

})
/**
 * 登录-成功函数回调方法方法
 */
function loginHandle(data) { 
	if(data.error_code == 10000) {
		var my_phone = data.data.account; //手机号码
		var user_id = data.data.user_id; //个人user_id 
		localStorage.setItem("my_phone", my_phone);
		localStorage.setItem("user_id", user_id);
		/*mui.openWindow({
			url: '../../Recommend.html',
			id: 'Recommend',
			createNew: true
		});*/
		window.top.location.href = '../../Recommend.html';
	} else {
		mui.alert(data.msg);
	}
}

/*
 * 注册——点击下一步
 */
document.getElementById("register_next_step").addEventListener("tap", function() {
	var register_phone = $("#register_phone").val(); //手机号码
	if(!register_phone) {
		mui.alert("请输入手机号码！")
		return false;
	}
	interfRequest.verification_code.data = {
		mobile: register_phone,
		type: 1
	}
	socialRequest(interfRequest.verification_code);
	mui.openWindow({
		url: 'register.html',
		id: 'register',
		extras: {
			register_phone: register_phone
		}
	});
})
/*
 * 注册_发送验证码方法
 */
function verification_codeHandle(data) {
	if(data.error_code == 10000) {
		console.log("注册_发送验证码 ==》" + JSON.stringify(data))
	} else {
		mui.alert(data.msg);
	}
}
/*
 * 注册_确定-成功函数回调方法
 */
function registerHandle(data) {
	if(data.error_code == 10000) {
		mui.alert("注册成功！")
		mui.openWindow({
			url: 'login.html',
			id: 'login',
		});
	} else {
		mui.alert(data.msg);
	}
}

//X
mui('body').on('tap', '.fxsj_close', function() {
	window.top.location.href = '../../Recommend.html';
}) 

//返回到首页
mui.back = function() {
	window.top.location.href = '../../Recommend.html';
}
